<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>

<body>
    <style>
        #container {
            width: 80%;
            height: 30px;
            display: flex;
            justify-content: center;
            align-items: center;
            /* overflow: hidden; */
            background-color: darkgray;
            margin: 0 auto;
        }

        ul,
        li {
            list-style: none;
        }

        #container>ul>li {
            float: left;
            position: relative;
            margin: 20px;
        }

        #container>ul>li ul {
            height: 70px;
            float: left;
            z-index: 10;
            width: 50px;
            position: absolute;
            left: -42px;
            background-color: darksalmon;
        }
    </style>
    <div id="container">
        <ul>
            <li>
                <a>首页</a>
                <ul>
                    <li>
                        首页1
                    </li>
                    <li>
                        首页2
                    </li>
                    <li>
                        首页3
                    </li>
                </ul>
            </li>
            <li>
                <a>长衫</a>
                <ul>
                    <li>
                        长衫1
                    </li>
                    <li>
                        长衫2
                    </li>
                    <li>
                        长衫3
                    </li>
                </ul>
            </li>
            <li>
                <a>卫衣</a>
                <ul>
                    <li>
                        卫衣1
                    </li>
                    <li>
                        卫衣2
                    </li>
                    <li>
                        卫衣3
                    </li>
                </ul>
            </li>
            <li>
                <a>裤子</a>
                <ul>
                    <li>
                        裤子1
                    </li>
                    <li>
                        裤子3
                    </li>
                    <li>
                        裤子2
                    </li>
                </ul>
            </li>
            <li>
                <a>联系我们</a>
            </li>
        </ul>
    </div>

    <script src="../js/jquery.3.5.1.js"></script>
    <script>
        $("#container>ul>li:has(ul)>ul").slideUp()
        $("#container>ul>li:has(ul)").hover(function () {
            $(this).children("ul").stop().slideDown();
        }, function () {
            $(this).children("ul").stop().slideUp()
        })
    </script>
</body>

</html>